package com.fmjava.service_video.controller;


import com.fmjava.service_video.entity.treeModel.TreeModel;
import com.fmjava.service_video.service.CategoryService;
import com.fmjava.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 科目分类 前端控制器
 * </p>
 *
 * @author fmjava
 * @since 2021-07-12
 */
@RestController
@Api(tags = "模板分类")
@RequestMapping("/service_video/category")
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    @PostMapping("/addCategory")
    @ApiOperation(value = "通过excel保存分类数据")
    public ResponseResult addCategory(@ApiParam(name = "file",value = "excel数据表",required = true) MultipartFile file){
        categoryService.addCategory(file);
        return ResponseResult.ok();
    }

    @GetMapping("/getTreeModel")
    @ApiOperation(value = "获取所有的分类列表")
    public ResponseResult getTreeModel(){
      List<TreeModel> treeModelList= categoryService.getTreeModelList();
        return ResponseResult.ok().data("list",treeModelList);
    }

}

